package calao.contact.client;

import com.google.gwt.user.client.ui.FlowPanel;

public class ContactList
extends FlowPanel
{
	
	final static String STYLE = "contact-ContactList";
	
	final ContactMod mod;

	ContactList(ContactMod mod)
	{
		this.mod = mod;
		addStyleName(STYLE);
	}
	
	void refreshWith(Contact[] info)
	{
		clear();
		java.util.Arrays.sort(info, Contact.getComparator());
		for (int i=0; i<info.length; i++) add(new ContactLink(info[i]) {
			protected void show(ContactPanel panel) {
				mod.getDesktop().setView(panel);
			}
		});
	}

}
